home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1193 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  66 lines

  1. Path: gate.net!pslfl2-14
  2. From: bhutto@gate.net (William Hutto)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Spawn and exit...
  5. Date: 11 Jan 1996 23:37:15 GMT
  6. Organization: CyberGate, Inc.
  7. Message-ID: <4d46vb$1vs0@news.gate.net>
  8. References: <4ckcjc$e84@oly.olympic.net> <DKyyE1.Bu5@news.zippo.com>
  9. NNTP-Posting-Host: pslfl2-14.gate.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <DKyyE1.Bu5@news.zippo.com>,
  13.    Jim McFarland <jgm6@orkand.em.cdc.gov> wrote:
  14. >poke@oly.olympic.net (Charlie Chaplin  ) wrote:
  15. >>I am having trouble writing a program that spwans my windows 3.11 then 
  16. >>kills itself. I realize that windows 3.11 would be a child process. The 
  17. >>parent process takes up so much memory that it slows my windows down too 
  18. >>much. The program that I wrote was a result of my father's complaints. 
  19. >>Whenever I get into debugging the computer I rem out the win statement in 
  20. >>the autoexec.bat, because I tend to reboot the computer a lot when I'm 
  21. >>debugging. This is a very long and tedious process if windows has to load 
  22. >>up every time(yes I know about F5, read on and you will understand). The 
  23. >>problem is, I forget to unrem the win statement, and my 
  24. >>semi-literate father can't figure out how to get word 6.0 working(Yes 
  25. >>I've told hime a million times to just type WIN), and he starts 
  26. >>hollering at me. If I hit F5 during reboot I don't get the path 
  27. >>statement the memory managers and the config.sys, which are necessary for 
  28. >>what I'm doing. So I wrote a program called win.exe and I placed it in my 
  29. >>root directory. WHen the autoexec.bat gets down to the win statement it 
  30. >>executes the local win.exe file. win.exe pauses the computer for about 4 
  31. >>seconds and then spawns windows 3.11. If any key is pressed during the 4 
  32. >>second pause the program exits and I am left with a DOS prompt. I just 
  33. >>need help getting my program to kill itself if it ends up spawning 
  34. >>windows 3.11, win.exe takes up almost 80K of memory when it's resident. I 
  35. >>have also tried the system() function, it does the same thing.
  36. >
  37. >Try using one of the execlp() type functions instead of spawning it.
  38.  
  39. This is a simple MS-DOS question and would be better asked in 
  40. comp.os.msdos.programmer or alt.msdos.programmer. Run your program from your 
  41. autoexec.bat file and return a non-zero value if a key is pressed. Then check 
  42. errorlevel when it returns to the batch file. You don't even need to delay 
  43. because the keypress is going to be buffered anyway. Tell your dad not to 
  44. touch any keys while it's booting.
  45.  
  46. /*checkkey.c*/
  47. #include <conio.h>
  48.  
  49. int main(void)
  50. {
  51.  
  52.     if(kbhit()) {
  53.         getch();
  54.         return 1;
  55.         }
  56.     return 0;
  57. }
  58.  
  59. /*last two lines of autoexec.bat*/
  60. checkkey
  61. if not errorlevel 1 win
  62.  
  63. Bill
  64.  
  65. "Whatcha got on?...Your mind?"
  66.